const express=require('express');
//对象实例化
const app=express();

var cookieParser = require('cookie-parser');
app.use(cookieParser());

//创建路由
//创建cookie
app.get('/set-cookie',(req,res)=>{
    // res.cookie('name','lili')  cookie会找浏览器关闭销毁
    res.cookie('name','lili',{maxAge:60*1000}/*生命周期为60秒*/)
    res.end('hello大厅');
});


//删除cookie
app.get('/remove-cookie',(req,res)=>{
    res.clearCookie('name')
    res.end('hello大厅');
});
//获取cookie
app.get('/get-cookie',(req,res)=>{
    console.log(req.cookies);
    res.send('欢迎你'+req.cookies.name);
})


//监听端口
app.listen(8000,()=>{
    console.log('服务启动成功');
})